Move logging into src/core.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Jun 2014 03:50:11 +0000 (03:50 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Jun 2014 03:50:11 +0000 (03:50 +0000)
gpsbabel/GPSBabel.pro
gpsbabel/gpx.cc
gpsbabel/logging.h [deleted file]
gpsbabel/lowranceusr.cc
gpsbabel/src/core/logging.h [new file with mode: 0644]
gpsbabel/waypt.cc

index a785781514598d5086f42bf04eab203c880e42a7..188e791f318e9ed1eb489190dcb424febb543945 100644 (file)
@@ -215,7 +215,6 @@ HEADERS =  \
        jeeps/gpsusbcommon.h \
        jeeps/gpsusbint.h \
        jeeps/gpsutil.h \
-       logging.h \
        magellan.h \
        mapsend.h \
        navilink.h \
@@ -237,7 +236,8 @@ HEADERS =  \
        zlib/zconf.in.h \
        zlib/zlib.h \
        zlib/zutil.h \
-       src/core/xmlstreamwriter.h
+       src/core/xmlstreamwriter.h \
+       src/core/logging.h
 
 SUBDIRS += jeeps
 
index feabd47e89fb2f465ddd34fa4f364a24aa42fffe..aedd74679526a5b504d5508b9c8c0e9ad9da99d6 100644 (file)
@@ -23,7 +23,7 @@
 #include "cet_util.h"
 #include "garmin_fs.h"
 #include "garmin_tables.h"
-#include "logging.h"
+#include "src/core/logging.h"
 #include <math.h>
 #include <QtCore/QXmlStreamReader>
 static QXmlStreamReader* reader;
@@ -860,18 +860,11 @@ xml_parse_time(const QString& dateTimeString)
 static void
 gpx_end(const QString& el)
 {
-  int pos = current_tag.lastIndexOf('/');
-  QString s = current_tag.mid(pos + 1);
   float x;
   int passthrough;
   static QDateTime gc_log_date;
   tag_type tag;
 
-  if (s.compare(el)) {
-//   TODO: I don't think this is necesary with QXmlStreamReader
-    fprintf(stderr, "Mismatched tag %s.  Expected %s\n", CSTR(el), qPrintable(s));
-  }
-
   tag = get_tag(current_tag, &passthrough);
   switch (tag) {
     /*
diff --git a/gpsbabel/logging.h b/gpsbabel/logging.h
deleted file mode 100644 (file)
index 1fe0700..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-    Copyright (C) 2014 Robert Lipe, robertlipe+source@gpsbabel.org
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
-
- */
-#ifndef gpsbabel_logging_h_included
-#define gpsbabel_logging_h_included
-
-// A wrapper for QTextStream that provides a sensible Warning() and Fatal()
-// with convenient stream operators.
-
-#include <QtCore/QTextStream>
-#include <QtCore/QFile>
-
-class Warning {
- public:
-  Warning(bool fatal = false) :
-   fatal_(fatal) {
-    file_.open(stderr, QIODevice::WriteOnly);
-    fileStream_.setDevice(&file_);
-  }
-  ~Warning() {
-    fileStream_ << '\n';
-    if (fatal_) {
-      fileStream_.flush();
-      exit(1);
-    }
-  }
-  inline Warning& operator << (char d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (signed short d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (unsigned short d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (signed int d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (unsigned int d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (signed long d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (unsigned long d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (qint64 d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (quint64 d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (float d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (double d) { fileStream_ << d; return optionalSpace(); }
-  inline Warning& operator << (const char* d) { fileStream_ << QString::fromUtf8(d); return optionalSpace(); }
-  inline Warning& operator << (QString d) { fileStream_ << '\"' << d << '\"'; return optionalSpace(); }
-  inline Warning& operator << (const void* d) { fileStream_ << '\"' << d << '\"'; return optionalSpace(); }
-
-  inline Warning& optionalSpace() {
-    fileStream_ << ' ';
-    return *this;
-  }
-private:
-  QFile file_;
-  QTextStream fileStream_;
-  bool fatal_;
-};
-
-class Fatal : public Warning {
- public:
-  Fatal() : Warning(true) {}
-};
-
-#endif //  gpsbabel_logging_h_included
index 4322a6cb1ffdc333d1b61505fef847facb3680b2..4f192496c0691b90823f4267d3406f53566942ee 100644 (file)
@@ -382,8 +382,6 @@ lowranceusr_parse_waypt(Waypoint* wpt_tmp)
 {
   char buff[MAXUSRSTRINGSIZE + 1];
   int text_len;
-  time_t waypt_time;
-  short waypt_type;
 
   wpt_tmp->latitude = lat_mm_to_deg(gbfgetint32(file_in));
   wpt_tmp->longitude = lon_mm_to_deg(gbfgetint32(file_in));
@@ -408,7 +406,7 @@ lowranceusr_parse_waypt(Waypoint* wpt_tmp)
     wpt_tmp->description = buff;
   }
   /* Time is number of seconds since Jan. 1, 2000 */
-  waypt_time = gbfgetint32(file_in);
+  time_t waypt_time = gbfgetint32(file_in);
   if (waypt_time) {
     wpt_tmp->SetCreationTime(base_time_secs + waypt_time);
   }
@@ -429,7 +427,7 @@ lowranceusr_parse_waypt(Waypoint* wpt_tmp)
   }
 
   /* Waypoint Type (USER, TEMPORARY, POINT_OF_INTEREST) */
-  waypt_type = gbfgetint16(file_in);
+  short waypt_type = gbfgetint16(file_in);
   if (global_opts.debug_level >= 1) {
     printf(MYNAME " parse_waypt: waypt_type = %d\n",waypt_type);
   }
diff --git a/gpsbabel/src/core/logging.h b/gpsbabel/src/core/logging.h
new file mode 100644 (file)
index 0000000..1fe0700
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+    Copyright (C) 2014 Robert Lipe, robertlipe+source@gpsbabel.org
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+#ifndef gpsbabel_logging_h_included
+#define gpsbabel_logging_h_included
+
+// A wrapper for QTextStream that provides a sensible Warning() and Fatal()
+// with convenient stream operators.
+
+#include <QtCore/QTextStream>
+#include <QtCore/QFile>
+
+class Warning {
+ public:
+  Warning(bool fatal = false) :
+   fatal_(fatal) {
+    file_.open(stderr, QIODevice::WriteOnly);
+    fileStream_.setDevice(&file_);
+  }
+  ~Warning() {
+    fileStream_ << '\n';
+    if (fatal_) {
+      fileStream_.flush();
+      exit(1);
+    }
+  }
+  inline Warning& operator << (char d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (signed short d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (unsigned short d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (signed int d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (unsigned int d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (signed long d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (unsigned long d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (qint64 d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (quint64 d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (float d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (double d) { fileStream_ << d; return optionalSpace(); }
+  inline Warning& operator << (const char* d) { fileStream_ << QString::fromUtf8(d); return optionalSpace(); }
+  inline Warning& operator << (QString d) { fileStream_ << '\"' << d << '\"'; return optionalSpace(); }
+  inline Warning& operator << (const void* d) { fileStream_ << '\"' << d << '\"'; return optionalSpace(); }
+
+  inline Warning& optionalSpace() {
+    fileStream_ << ' ';
+    return *this;
+  }
+private:
+  QFile file_;
+  QTextStream fileStream_;
+  bool fatal_;
+};
+
+class Fatal : public Warning {
+ public:
+  Fatal() : Warning(true) {}
+};
+
+#endif //  gpsbabel_logging_h_included
index 44b8608312ddedf2b1a6504741b43d4e833f7fb8..612c8ba523e404893644d4628ddd06e7c14e7460 100644 (file)
@@ -29,8 +29,7 @@
 #include "grtcirc.h"
 #include "garmin_fs.h"
 #include "session.h"
-
-#include <logging.h>
+#include "src/core/logging.h"
 
 #if NEWQ
 QList<Waypoint*> waypt_list;